-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Multi-axis Shapes #7666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Multi-axis Shapes #7666
Conversation
Co-authored-by: Alex Johnson <alex@plot.ly>
| var hasDrawnY = yParams.drawn !== undefined; | ||
|
|
||
| // Use vertex indices for array refs (same converter for all params in segment) | ||
| var segmentX2p = (isArrayXref && xSizemode !== 'pixel') ? x2p[xVertexIndex] : x2p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, so if isArrayXref is true but xSizemode is 'pixel', the variable segmentX2P gets assigned the value of x2p, but x2p would be an array of functions, not a function, correct? That seems like a bug. Unless I'm missing something.
| * extraOption if there is no axis) | ||
| * extraOption: aside from existing axes with this letter, what non-axis value is allowed? | ||
| * Only required if it's different from `dflt` | ||
| * extraOption: fallback value, only required if it's different from `dflt` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for changing this docstring? The previous version seems clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if you want to rephrase without the question mark, could say something like Additional non-axis value to allow. Only required if different from dflt
| 'a fixed width while maintaining a position relative to data or', | ||
| 'plot fraction.' | ||
| 'plot fraction.', | ||
| 'Note: *pixel* mode is not supported when `xref` is an array.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 'Note: *pixel* mode is not supported when `xref` is an array.' | |
| 'Note: `xsizemode` *pixel* is not supported when `xref` is an array.' |
| 'a fixed height while maintaining a position relative to data or', | ||
| 'plot fraction.' | ||
| 'plot fraction.', | ||
| 'Note: *pixel* mode is not supported when `yref` is an array.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 'Note: *pixel* mode is not supported when `yref` is an array.' | |
| 'Note: `ysizemode` *pixel* is not supported when `xref` is an array.' |
| {type: 'path', xref: ['x', 'x2'], yref: ['y', 'y2'], path: 'M1,1L2,2'} | ||
| ] | ||
| }).then(function() { | ||
| expect(getShape(0)).not.toBe(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. This isn't quite right. getShape(n) will never return null, it will either return a selection of size 1, or it will fail the assertion inside the function.
I mean it WORKS in that this test will still fail if each shape isn't present exactly once, but the logic is bad.
| var lineExpectedRight = xa2.l2p(2) + xa2._offset; | ||
| var lineBBox = getBoundingBox(0); | ||
|
|
||
| expect(lineBBox.left).toBeCloseTo(lineExpectedLeft); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why top and bottom aren't tested in this test?
| var lineExpectedTop = ya2.l2p(20) + ya2._offset; | ||
| var lineBBox = getBoundingBox(0); | ||
|
|
||
| expect(lineBBox.bottom).toBeCloseTo(lineExpectedBottom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, is there a reason why left and right aren't tested here?
| .then(done, done.fail); | ||
| }); | ||
|
|
||
| it('updates shape when panning a referenced axis', function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really test panning, it only tests updating the axis range via relayout. Test description should reflect that.
| x0: 0, x1: 5, y0: 0, y1: 5 | ||
| }] | ||
| }).then(function() { | ||
| expect(gd._fullLayout.xaxis.range[0]).toBeLessThan(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be less than 1 even without the shape, since there is a data point at x=1. Should test that it's less than 0 (and test for a lower bound as well).
Same goes for the y axis.
Also the test is only checking xaxis.range[0], yaxis.range[0], xaxis2.range[1] and yaxis2.range[1].
Should also be checked: xaxis.range[1], yaxis.range[1], xaxis2.range[0] and yaxis2.range[0].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@alexshoe This is looking really good. 🎉 I left some minor comments on the implementation (mostly style and readability) and also noticed some issues with the Jasmine tests. Could you do a pass through all the Jasmine tests and make sure they make sense, are testing the right things, etc. I also realized there's a pretty good chance that |
Description:
Extends
xrefandyrefto accept arrays, allowing shapes to span multiple subplots with each vertex anchored to a different axis. See #7151 for more information.Example:
Progress:
xrefandyrefto allow array values